#ifndef STRBLOB_H
#define STRBLOB_H
#include<iostream>
#include<vector>
#include<string>
#include<memory>
using namespace std;
class StrBlobPtr;
class StrBlob{
friend class StrBlobPtr;
friend bool operator==(const StrBlob &sb1,const StrBlob &sb2);
public:
	typedef vector<string>::size_type size_type;
	StrBlob();
	StrBlob(initializer_list<string> il);
	StrBlob(const StrBlob &sb){ data = make_shared<vector<string>>(*sb.data);}
	StrBlob& operator=(const StrBlob &sb){data = make_shared<vector<string>>(*sb.data);return *this;}
	size_type size() const {return data->size();}
	bool empty() const {return data->empty();}
	void push_back(const string &t){data->push_back(t);}
	void pop_back();
	string& front();
	string& front() const;
	string& back();
	string& back() const;
	StrBlobPtr begin();
	StrBlobPtr end();
private:
	shared_ptr<vector<string>> data;
	void check(size_type i,const string &msg)const;
	string& do_front()const {check(0,"front on empty StrBlob");return data->front();}
	string& do_back()const {check(0,"back on empty StrBlob");return data->back();}
};
bool operator==(const StrBlob &sb1,const StrBlob &sb2);
bool operator!=(const StrBlob &sb1,const StrBlob &sb2);
bool operator==(const StrBlob &sb1,const StrBlob &sb2)
{
	return *(sb1.data)==*(sb2.data);	
}
bool operator!=(const StrBlob &sb1,const StrBlob &sb2)
{
	return !(sb1==sb2);
}
StrBlob::StrBlob():data(make_shared<vector<string>>()){}
StrBlob::StrBlob(initializer_list<string> il):data(make_shared<vector<string>>(il)){}
void StrBlob::check(size_type i,const string &msg)const
{
	if(i>=data->size())
		throw out_of_range(msg);
}
string& StrBlob::front()
{
	do_front();
}
string& StrBlob::front() const
{
	do_front();
}
string& StrBlob::back()
{
	do_back();
}
string& StrBlob::back() const
{
	do_back();
}
void StrBlob::pop_back()
{
	check(0,"pop_back on empty StrBlob");
	data->pop_back();
}

#endif